import React, { Component } from 'react'
// import'./index.css';
import axios from 'axios';
import qs from 'querystring';
export default class HeroDetail extends Component {
        state = {
            hero: {}
        }   
        render() {
            return (
                <div>
                    <img width="100%" src={"http://192.168.36.33:3002" + this.state.hero.big_image} alt="" />
                </div>
            )
        }
    
        async componentDidMount(){
            //获取 id
            // let id = this.props.match.params.id;
            // console.log(id);
            let searchStr = this.props.location.search.slice(1);
            console.log(this.props);
            let tmp = qs.parse(searchStr);
            //根据 id 发送 AJAX 请求
            let result = await axios('http://192.168.36.33:3002/heros/' + tmp.id);
            this.setState({
                hero: result.data
            })
        }
}
